class Api::StorePositionsController < Api::BaseController
  before_action :login_required, :set_store
  def create
    @store_position = @store.positions.new(store_position_params)
    if @store_position.save
      render json: {status: true, store_position: @store_position}
    else
      render json: {status: false, message: @store_position.errors.full_messages.first}
    end
  end

  def update
    set_position
    @position.update(name: params[:name])
    render json: {status: true}
  end

  private
  def set_store
    @store ||= current_store
  end

  def store_position_params
    params.permit(:store_department_id, :name)
  end

  def set_position
    @position = StorePosition.find(params[:id])
  end
end
